package com.matt.repository.impl;

import com.matt.repository.base.BaseNativeSqlRepository;
import com.matt.repository.base.ChildrenLiveRecordRepository;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2017/8/4
 * *******************************
 */
@Service
public class ChildrenLiveRecordRepositoryImpl extends BaseNativeSqlRepository implements ChildrenLiveRecordRepository{

    @Override
    public List<Object[]> findChildrenByLiveRecord(String liveRecordId) {
        String findChildrenSql = String.format("select  c.name , c.imgUrl , c.gender"
                        + " from rel_children_live_record rr LEFT join children c on rr.childrenId = c.id WHERE rr.liveRecordId = '%s'",
                liveRecordId);
        List<Object[]> objectArrayList = sqlArrayList(findChildrenSql);
        return objectArrayList;
    }

    @Override
    public List<Object[]> findRecordsByChildren(String childrenId) {
        String findChildrenSql = String.format("select  l.id , l.mediaType "
                        + " from rel_children_live_record rr LEFT join live_record l on rr.liveRecordId = l.id WHERE rr.childrenId = '%s' and l.deleted='%s' ",
                childrenId, false);
        List<Object[]> objectArrayList = sqlArrayList(findChildrenSql);
        return objectArrayList;
    }


}
